// pages/index/index.js

Page({
    onShareAppMessage() {
        return {
          title: 'swiper',
          path: 'page/component/pages/swiper/swiper'
        }
      },
    
      data: {
        background: [{
            picture:'/images/猪肉脯.jpg',
        }, 
        ],
        pictureLink: [
            {
            picture:'/images/格子衬衫.jpg',
            intro:'浅蓝色高腰微喇叭牛仔裤',
            price:'99',
            categoryId:'',
            }
        ],
        indicatorDots: true,
        vertical: false,
        autoplay: true,
        interval: 2000,
        duration: 500
      },

      queryRecommend() {
          var that = this;
            wx.request({
                url: 'http://localhost:8080/recommend/search',
                method:'POST',
                header:{
                    'content-type':'application/json'
                },
                success:function(res) {
                    console.log(res);
                    that.setData({
                        pictureLink:res.data.data,
                    });
                },
                fail:function() {
                    console.log("失败");
                }
            })
        },
        queryAd() {
            var that = this;
            wx.request({
                url: 'http://localhost:8080/ad/search',
                method:'POST',
                header:{
                    'content-type':'application/json'
                },
                success:function(res) {
                    console.log(res);
                    that.setData({
                        background:res.data.data,
                    });
                },
                fail:function() {
                    console.log("失败");
                }
            })
        },
        jumpIntro(e){
            var that = this;
            var item = e.currentTarget.dataset.index;
            wx.navigateTo({
              url: '/pages/product information/product information?proId='+item.pro_id,
            })
        },
        jumpSearch(){
            wx.navigateTo({
              url: '/pages/search one/search one',
            })
        },
      onShow() {
        this.queryAd();
        this.queryRecommend();
        
      },
      
      
})
